﻿
'get user site random key
Public Class usrk
    Inherits requestProcessor

    Public Const _pathidentity As String = usrkPathIdentity

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Public Overrides Function process(ByVal context As httpContext) As Boolean
        assert(Not context Is Nothing)
        Dim id As String = Nothing
        id = context.url().query(query.id)
        If isemptystring(id) Then
            context.setstatuscode(uskResponse.statusCode.noIdInput, uskResponse.description.noIdInput)
        Else
            Dim host As String = Nothing
            host = context.url().query(query.host)
            If isemptystring(host) Then
                context.setstatuscode(uskResponse.statusCode.noHostInput, uskResponse.description.noHostInput)
            Else
                Dim ip As String = Nothing
                ip = context.requestIp()
                If ipVerify(ip) Then
                    Dim key As String = Nothing
                    If userSiteRandomKey(id, host, ip, key) Then
                        context.writer().Write(key)
                        context.setstatuscode(uskResponse.statusCode.success, uskResponse.description.success)
                    Else
                        context.setstatuscode(uskResponse.statusCode.notfound, uskResponse.description.notfound)
                    End If
                Else
                    context.setstatuscode(uskResponse.statusCode.noValidIp, uskResponse.description.noValidIp)
                End If
            End If
        End If
        Return True
    End Function
End Class
